package com.passionfruit.module.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.passionfruit.module.entity.BlogArticleCateLink;
import com.passionfruit.module.entity.SysRoleMenu;
import com.passionfruit.module.mapper.BlogArticleCateLinkMapper;
import com.passionfruit.module.service.IBlogArticleCateLinkService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.xiaoleilu.hutool.convert.Convert;
import org.springframework.stereotype.Service;

import javax.persistence.criteria.CriteriaBuilder;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author weirdor
 * @since 2017-11-06
 */
@Service
public class BlogArticleCateLinkServiceImpl extends ServiceImpl<BlogArticleCateLinkMapper, BlogArticleCateLink> implements IBlogArticleCateLinkService {

    @Override
    public void saveOrUpdate(Integer aritcleId, Integer cateId) {
        //先删除角色与菜单关系
        EntityWrapper<BlogArticleCateLink> ew=new EntityWrapper<>();
        ew.eq("article_id",aritcleId);
        super.delete(ew);
        //保存角色与菜单关系
            BlogArticleCateLink blogArticleCateLink=new BlogArticleCateLink();
            blogArticleCateLink.setArticleId(aritcleId);
            blogArticleCateLink.setCateId(cateId);
            super.insertOrUpdate(blogArticleCateLink);
    }
	
}
